﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;

namespace WindowsFormsApplication2.Model
{
    class Layanan
    {

        int id;
        string nama;
        int durasi_menit;

        public Layanan()
        {

        }

        public Layanan(int _Nama)
        {
            Database db = new Database();
            DataSet ds = new DataSet();
            DataTable dt = new DataTable();
            string sql = "SELECT * FROM layanan WHERE nama = '" + _Nama + "'";

            db.Open();
            ds = db.ExecuteQuery(sql);
            dt = ds.Tables[0];
            DataRow dr = dt.Rows[0];

            id = (int)dr[0];
            nama = (string)dr[1];
            durasi_menit = (int)dr[2];

            db.Close();
        }

        public ArrayList daftarLayanan(int _id_layanan)
        {
            return null;
        }

        public void addLayanan()
        {
            Database db = new Database();
            string sql = "INSERT INTO layanan(nama, durasi_menit) VALUES ('" + nama.ToString() + "','" + durasi_menit.ToString() + "')";
            db.Open();
            db.ExecuteNonQuery(sql);
            db.Close();

        }

        public void updateLayanan()
        {
        }

        public void deleteLayanan()
        {
        }

    }
}
